package org.ruanjj.maxsubarray;

public class Solution {
    public int maxSubArray(int[] nums) {
        int max = nums[0];
        int pre = 0;
        for(int x:nums){
            pre = Math.max(pre+x,x);
            max = Math.max(max, pre);
        }

        return max;
    }
}
